// ----------------------------------
// RSDK Project: Sonic 2 - Boss Attack Plus
// Script Description: Results
// Script Author: Tails LP
// ----------------------------------

//-------Aliases-------//

private alias object.value0 : object.timer
private alias object.value1 : start.fadeValue
private alias object.value2 : selection.current
private alias object.value3 : arrow.offset
private alias object.value4 : object.aniTileTImer
private alias object.value5 : object.aniTileFrame

// menu selections


//private alias 0 : 

// object states

private alias 0 : STARTING_UP
private alias 1 : FADE_IN
private alias 2 : CHAR_SELECT
private alias 3 : MENU_IDLE
private alias 4 : BACK_TO_MENU

// selections

// Game Modes

private alias 0 : BOTH
private alias 1 : S_ONE
private alias 2 : S_TWO

private alias saveRAM[494] : saved.bossGameMode //7B8 SData.bin
private alias saveRAM[495] : saved.bossType //7BC SData.bin
private alias saveRAM[496] : saved.BossMusic //7C0 SData.bin
private alias saveRAM[497] : saved.Character //7C4 SData.bin
private alias saveRAM[498] : saved.TimeLimit //7C8 SData.bin
private alias saveRAM[499] : saved.superMode //7CC SData.bin

private alias saveRAM[500] : bossAttackTime.SonicTails //7D0 SData.bin
private alias saveRAM[501] : bossAttackTime1.SonicTails //7D4 SData.bin
private alias saveRAM[502] : bossAttackTime2.SonicTails //7D8 SData.bin

private alias saveRAM[503] : bossAttackTime.Sonic //7DC SData.bin
private alias saveRAM[504] : bossAttackTime1.Sonic //7E0 SData.bin
private alias saveRAM[505] : bossAttackTime2.Sonic //7E4 SData.bin

private alias saveRAM[506] : bossAttackTime.Tails //7E8 SData.bin
private alias saveRAM[507] : bossAttackTime1.Tails //7EC SData.bin
private alias saveRAM[508] : bossAttackTime2.Tails //7F0 SData.bin

private alias saveRAM[509] : bossAttackTime.Knuckles //7F4 SData.bin
private alias saveRAM[510] : bossAttackTime1.Knuckles //7F8 SData.bin
private alias saveRAM[511] : bossAttackTime2.Knuckles //7FC SData.bin

private alias saveRAM[512] : bossAttackTime.KnucklesTails //800 SData.bin
private alias saveRAM[513] : bossAttackTime1.KnucklesTails //804 SData.bin
private alias saveRAM[514] : bossAttackTime2.KnucklesTails //808 SData.bin

private alias saveRAM[515] : bossAttackTime.SuperSonic //80C SData.bin
private alias saveRAM[516] : bossAttackTime1.SuperSonic //810 SData.bin
private alias saveRAM[517] : bossAttackTime2.SuperSonic //814 SData.bin

private alias saveRAM[518] : bossAttackTime.SuperTails //818SData.bin
private alias saveRAM[519] : bossAttackTime1.SuperTails //81C SData.bin
private alias saveRAM[520] : bossAttackTime2.SuperTails //820 SData.bin

private alias saveRAM[521] : bossAttackTime.SuperKnuckles //824 SData.bin
private alias saveRAM[522] : bossAttackTime1.SuperKnuckles //828 SData.bin
private alias saveRAM[523] : bossAttackTime2.SuperKnuckles //82C SData.bin

//-------Function declarations-------//

//-------Static Values-------//

//-------Tables-------//




//-------Functions-------//



event ObjectMain

	switch object.state
	case STARTING_UP
		ReadSaveRAM()
		start.fadeValue = 276
		SetScreenFade(0, 0, 0, start.fadeValue)
		object.state = FADE_IN
		break
	case FADE_IN
		if start.fadeValue > 0
			start.fadeValue -= 12
		else
			start.fadeValue = 0
			object.state = MENU_IDLE
		endif
		SetScreenFade(0, 0, 0, start.fadeValue)
		break
	case MENU_IDLE
		temp0 = inputPress.ButtonA
		temp0 |= inputPress.ButtonB
		temp0 |= inputPress.ButtonC
		temp0 |= inputPress.Start
		if temp0 == 1
			object.state = BACK_TO_MENU
			object.timer = 0
			selection.current = 0
		endif
		break
	case BACK_TO_MENU
			SetScreenFade(0, 0, 0, start.fadeValue)
			start.fadeValue += 12
			music.volume -= 5
			if start.fadeValue >= 256
				temp4 = 0
				stage.activeList = PRESENTATION_STAGE
				stage.listPos = 3
				WritesaveRAM()
				LoadStage()
			endif
		break
	endswitch


end event

event ObjectDraw
//----------------------HEADER------------------------------------

	temp1 = 16
	DrawSpriteScreenXY(0, screen.xcenter, temp1)

//----------------------CHARACTER SELECT--------------------------


end event

event ObjectStartup
	ReadSaveRAM()
	if stage.listPos == 4
		if saved.bossGameMode == 1
			Stage[0].ActiveLayer=2
		else
			Stage[0].ActiveLayer=1
			tileLayer[1].scrollPos = 0xa00000
		endif
		SetMusicTrack("ActComplete.ogg", 0, 0)
	endif
	PlayMusic(0)

	LoadSpriteSheet("LevelSelect/Icons.gif")
	SpriteFrame(-83, -7, 167, 14, 327, 5)			//00 STAGE CLEAR HEADER
end event

event RSDKDraw
    DrawSprite(0)
end event

event RSDKLoad
    LoadSpriteSheet("Global/Display.gif")
    SpriteFrame(-16, -16, 32, 32, 223, 172)
end event